import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [{
        path: "/",
        redirect: "/layout",
    },
    {
        path: "/login",
        name: "login",
        component: () =>
            import ("../views/login/index.vue"),
    },
    // layout配置二级路由 所有的页面都在layout的
    // contentCom中出现
    {
        path: "/layout",
        name: "layout",
        component: () =>
            import ("../views/layout.vue"),
        // 二级路由  自动在contentCom中切换
        children: [{
                path: "/",
                name: "home",
                component: () =>
                    import ("../views/Home/index.vue"),
            },
            {
                path: "cart",
                name: "cart",
                component: () =>
                    import ("../views/Cart/index.vue"),
            },
            {
                //详情页的路由
                path: "detail",
                name: "detail",
                component: () =>
                    import ("../views/Detail/index.vue"),
            },
            // 订单模块
            {
                path: "order",
                name: "order",
                component: () =>
                    import ("../views/Order/index.vue"),
            },
            // 分类详情
            {
                path: "catedetail",
                name: "catedetail",
                component: () =>
                    import ("../views/cateTwo/index.vue"),
            },
            {
                // vue设置的固定必传参数
                path: "cateinfo/:id",
                name: "cateinfo",
                component: () =>
                    import ("../views/cateDetail/index.vue"),
            },
        ],
    },
];

const router = new VueRouter({
    mode: "history",
    base: process.env.BASE_URL,
    routes,
});

export default router;